package com.example.everying.controller.feedback;/*
 * 项目名称: everything
 * 文件名: UserComplaintsController
 * 作者: 张泽阳
 * 日期: 2025/5/28
 * 描述:
 */

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.everying.model.dto.feedback.ComplaintsPageDto;
import com.example.everying.model.entity.feedback.UserComplaints;
import com.example.everying.model.vo.feedback.UserComplaintsVo;
import com.example.everying.service.feedback.UserComplaintsService;
import com.example.everying.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/complaints")
public class UserComplaintsController {

    @Autowired
    private UserComplaintsService userComplaintsService;
    @PostMapping("/addComplaints")
    public Result<?> addComplaints(@RequestBody UserComplaints userComplaints){

        return userComplaintsService.addComplaints(userComplaints);
    }
    @PostMapping("/list")
    public Result<?> list(@RequestBody ComplaintsPageDto complaintsPageDto){
        return userComplaintsService.list(complaintsPageDto);
    }

    @PostMapping("/page")
    public Result<?> page(@RequestBody ComplaintsPageDto complaintsPageDto){
        Page<UserComplaintsVo> pageParam = new Page<>(complaintsPageDto.getPage(),  complaintsPageDto.getLimit());
        return userComplaintsService.selectPageWithUser(pageParam, complaintsPageDto);
    }
}
